package com;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class Favorites {
    private Map<Class<?>,Object> mFavorites = new HashMap<>() ;

    public <T> void putFavorite(Class<T> type,T instance){
        mFavorites.put(Objects.requireNonNull(type),instance) ;
    }

    public <T> T getFavorite(Class<T> type){
        return type.cast(mFavorites.get(type)) ;
    }
}
